<div class="bjui-pageHeader">
    <form id="pagerForm" data-toggle="ajaxsearch" action="${request.getContextPath()}/PartProgress/partProgress" method="post">
        <div class="bjui-searchBar">
            <g:hiddenField name="SYS_QUERY_NAME" value="partProgress" />
            <g:hiddenField name="EXPORT_CONTENT_NAME" value="Excel" />
            <label >工序：</label>&nbsp;
        <g:select name="step" from="${partProgressStepList}" data-toggle="selectpicker" data-live-search="true" optionKey="step" optionValue="step" value="${step}" noSelection="['':'ALL']" />&nbsp;
            <label >产品：</label>&nbsp;
        <g:select name="part" from="${partProgressPartList}" data-toggle="selectpicker" data-live-search="true" optionKey="part" optionValue="part" value="${part}" noSelection="['':'ALL']" />&nbsp;

            <label >时间段：</label>&nbsp;
            <input type="text" name="startTime" value="${startTime}" data-pattern="yyyy-MM-dd"  data-toggle="datepicker" placeholder="FROM">
            <input type="text" name="endTime" value="${endTime}" data-pattern="yyyy-MM-dd" data-toggle="datepicker" placeholder="TO">&nbsp;&nbsp;
            <label >方向：</label>&nbsp;
            <g:select name="partDirection" from="${partDirectionList}" data-toggle="selectpicker" data-live-search="true" optionKey="text" optionValue="text" value="${partDirection}" noSelection="['':'ALL']" />&nbsp;

            <button type="submit" class="btn-default" data-icon="search">查询</button>&nbsp;
            <button type="button" class="btn-blue" onclick="javascript:bjuiExportExl('#pagerForm','${request.getContextPath()}/PartProgress/exportExcel')" data-icon="file-excel-o" title="导出Excel">导出</button>&nbsp;
        </div>
    </form>
</div>

<div class="bjui-pageContent">
    <g:if test="${partProgress.size() > 0}">
        <table  data-toggle="tablefixed" data-width="100%" data-nowrap="true">
            <thead>
            <tr id="t1">
                <g:each in="${tableHeadList}" status="j" var="headInstance">
                    <g:if test="${headInstance!='RN'}">
                        <th  width="125"><g:message code="${headInstance}" default="${headInstance}"/></th>
                    </g:if>
                </g:each>
            </tr>
            </thead>
            <tbody>
            <g:if test="${partProgress.size()>0}">
                <g:each in="${partProgress}" status="i" var="dataInstance">
                    <tr>
                        <g:each in="${tableHeadList}" status="j" var="headInstance">
                            <g:if test="${headInstance=='NORMAL_QTY'}">
                                <td name="progressNormal${i+1}">
                                    <a href="${request.getContextPath()}/PartProgress/partProgressStep?docId=<%=dataInstance.DOC_ID%>&recpId=<%=dataInstance.RECIPE_VERSION%>&state=<%=dataInstance.ZH%>" data-toggle="navtab"  data-id="dialog-normal" data-options="{id:'partProgressStep', title:'产品进度跟总表二阶'}">${dataInstance["${headInstance}"] }</a>
                                </td>
                            </g:if>
                            <g:elseif test="${headInstance=='REWORK_QTY'}">
                                <td name="progressRework${i+1}">
                                    <a href="${request.getContextPath()}/PartProgress/partProgressStep?docId=<%=dataInstance.DOC_ID%>&recpId=<%=dataInstance.RECIPE_VERSION%>&state=<%=dataInstance.ZH%>" data-toggle="navtab"  data-id="dialog-normal" data-options="{id:'partProgressStep', title:'产品进度跟总表二阶'}">${dataInstance["${headInstance}"] }</a>
                                </td>
                            </g:elseif>
                            <g:elseif test="${headInstance=='OUTSRC_QTY'}">
                                <td name="progressOrc${i+1}">
                                    <a href="${request.getContextPath()}/PartProgress/partProgressStep?docId=<%=dataInstance.DOC_ID%>&recpId=<%=dataInstance.RECIPE_VERSION%>&state=<%=dataInstance.ZH%>" data-toggle="navtab"  data-id="dialog-normal" data-options="{id:'partProgressStep', title:'产品进度跟总表二阶'}">${dataInstance["${headInstance}"] }</a>
                                </td>
                            </g:elseif>
                            <g:elseif test="${headInstance=='SCRAP_QTY'}">
                                <td name="progressScrap${i+1}">
                                    <a href="${request.getContextPath()}/PartProgress/partProgressStep?docId=<%=dataInstance.DOC_ID%>&recpId=<%=dataInstance.RECIPE_VERSION%>&state=<%=dataInstance.ZH%>" data-toggle="navtab"  data-id="dialog-normal" data-options="{id:'partProgressStep', title:'产品进度跟总表二阶'}">${dataInstance["${headInstance}"] }</a>
                                </td>
                            </g:elseif>
                            <g:elseif test="${headInstance!='RN'}">
                                <td>${dataInstance["${headInstance}"]}</td>
                            </g:elseif>
                        </g:each>
                    </tr>
                </g:each>
                <tr>

                    <td colspan="12">小计</td>
                    <td id="normalShow"></td>
                    <td id="reworkShow"></td>
                    <td id="orcShow"></td>
                    <td id="scrapShow"></td>
                </tr>
                <tr>

                    <td colspan="12">合计</td>
                    <td>${partProgressSumQty[0].NORMAL_SUM}</td>
                    <td>${partProgressSumQty[0].REWORK_SUM}</td>
                    <td>${partProgressSumQty[0].OUTSRC_SUM}</td>
                    <td>${partProgressSumQty[0].SCRAP_SUM}</td>
                </tr>

            </g:if>
            <g:else>
                <g:render template="../template/emptyPanel" />
            </g:else>
            </tbody>
        </table>
    </g:if>
</div>
<g:render template="../template/pagination" />

<script>
    $(function(){
        /*获取当页正常数量的小计*/
        var progressN=0
        for(var i=1;i<=${partProgress.size()};i++){
            var progressNo='progressNormal'+i
            var progressNor=$("td[name='"+progressNo+"']").text()==''?0:parseInt($("td[name='"+progressNo+"']").text());
            progressN+=progressNor
        }
        $("#normalShow").html(progressN);

        /*获取当页返修数量的小计*/
        var progressR=0
        for(var i=1;i<=${partProgress.size()};i++){
            var progressRe='progressRework'+i
            var progressRew=$("td[name='"+progressRe+"']").text()==''?0:parseInt($("td[name='"+progressRe+"']").text());
            progressR+=progressRew
        }

        $("#reworkShow").html(progressR);

        /*获取当页外协数量的小计*/
        var progressO=0
        for(var i=1;i<=${partProgress.size()};i++){
            var progressOr='progressOrc'+i
            var progressOrc=$("td[name='"+progressOr+"']").text()==''?0:parseInt($("td[name='"+progressOr+"']").text());
            progressO+=progressOrc
        }
        $("#orcShow").html(progressO);

        /*获取当页报废数量的小计*/
        var progressS=0
        for(var i=1;i<=${partProgress.size()};i++){
            var progressSc='progressScrap'+i
            var progressScr=$("td[name='"+progressSc+"']").text()==''?0:parseInt($("td[name='"+progressSc+"']").text());
            progressS+=progressScr
        }
        $("#scrapShow").html(progressS);


    })
</script>

